package com.sushi.controller;

import com.sushi.service.PostService;
import com.sushi.response.ResponseBO;
import com.sushi.response.ResponsePageBO;
import com.sushi.response.PostResp;
import com.sushi.request.PostReq;
import com.sushi.request.PostPageReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.*;

/**
 * 交流帖 控制器
 * @date 2023-05-02
 * @time 17:15:45
 * @author Administrator
 */
@RestController
@Slf4j
public class PostController {

	@Autowired
	private PostService postService;

    

    /**
     * 新增
     */
    @PostMapping("/post/add")
    public ResponseBO<PostResp> add(@RequestBody PostReq req) {
        return postService.add(req);
    }

    /**
     * 逻辑删除
     */
    @PostMapping("/post/remove")
    public ResponseBO<PostResp> remove(@RequestBody PostReq req) {
        return postService.logicRemove(req);
    }

    /**
     * 更新
     */
    @PostMapping("/post/update")
    public ResponseBO<PostResp> update(@RequestBody PostReq req) {
        return postService.updateByField(req);
    }

    /**
     * 列表
     */
    @PostMapping("/post/list")
    public ResponsePageBO<PostResp> list(@RequestBody PostPageReq req) {
        return postService.listByCondition(req);
    }

    /**
     * 详情
     */
    @PostMapping("/post/detail")
    public ResponseBO<PostResp> detail(@RequestBody PostReq req) {
        return postService.detail(req);
    };

}